﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UMLDesigner
{
    static class WindowsManager
    {
        private static MainWindow mainWindow;
        
        private static List<ClassView> classes = new List<ClassView>();

        private static ClassView selectedClass = null;
        private static RelationView relationToCreate = null;
        
        public static Form Build() {
            mainWindow = new MainWindow();
            return mainWindow;
        }

        public static void SelectClass(ClassView classView)
        {
            if (relationToCreate != null && selectedClass!=null)
            {
                //Now it's possible to paint the relation
                relationToCreate.SetIniClass(selectedClass);
                relationToCreate.SetEndClass(classView);
                mainWindow.PaintRelation(relationToCreate);
                relationToCreate = null;
            }

            DeselectClass();
            selectedClass = classView;
            selectedClass.Select();
        }

        public static void DeselectClass()
        {
            if (selectedClass != null)
            {
                selectedClass.Deselect();
                selectedClass = null;
            }
        }

        public static void SetRelationToCreate(RelationView rel)
        {
            relationToCreate = rel;
        }

        public static void AddClass(ClassView clase)
        {
            classes.Add(clase);
        }
    }
}
